package demo01.aop;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.stereotype.Component;

/**
 * Created by ztt on 2017/9/24.
 */
@Aspect
@Component
public class Aop01 {

    @Pointcut("execution(public * demo01.bean..*.*(..))")
    public void recordLog(){}

    @Before("execution ( ** demo01.bean.Performance.perform(..))")
    public void silenceCellPhones(){
        System.out.println("@Before…… ");
    }

    @After("execution ( ** demo01.bean.Performance.perform(..))")
    public void After(){
        System.out.println("@After…… ");
    }

    @AfterReturning("execution ( ** demo01.bean.Performance.perform(..))")
    public void afterreturn(){
        System.out.println("@AfterReturning…… ");
    }

    @AfterThrowing("execution ( ** demo01.bean.Performance.perform(..))")
    public void afterThrowing(){
        System.out.println("@AfterThrowing…… ");
    }

    @Around("execution ( ** demo01.bean.Performance.perform(..))")
    public void around(ProceedingJoinPoint pj){
        System.out.println("@Around……之前 ");
        try {
            pj.proceed();
        } catch (Throwable throwable) {
            throwable.printStackTrace();
        }
        System.out.println("@Around……之后 ");
    }
}
